package com.my.study;


import com.my.interview.Father;
import com.my.interview.Son;

import java.util.ArrayList;
import java.util.List;

public class CollectionStudy {

    public static void main(String[] args) {

        List a1 = new ArrayList();
        a1.add(new Object());
        a1.add(new Integer(128));
        a1.add(new String("hello alala"));
        System.out.println(a1);


        List<Object> a2 = a1;
        a2.add(new Object());
        a2.add(new Integer(222));
        a2.add(new String("hello alala2"));
        System.out.println(a2);


        List<Integer> a3 = a1;
        a3.add(new Integer(333));
        System.out.println(a3);


        //List<?> 为通配符集合，他可以接受任何类型的集合引用复制，不能添加任何元素，但可以remove和clear
        List<?> a4 = a1;
        a4.remove(0);
        //a4.clear();
        //List <?> 泛型不能增加new Object元素
        //a4.add(new Object());
        System.out.println(a4);

        //super T及T的父类的集合，get受限，因为不知道是哪个
        List<? super Father> a5 = new ArrayList<>();
        a5.add(new Father());
        a5.add(new Son());
        Father father = (Father) a5.get(0);


        //extends put功能首先， T及T子类的集合
        List<? extends Father> a6 = new ArrayList<>();

    }


}
